<template>
  <div>
    <el-container>
      <el-main>
        <el-row>
          <el-col :span="6" style="width: 25%;">
            <el-card shadow="always">
              <el-form :label-position="labelPosition" label-width="80px">
                <el-form-item label="缴费人员">
                  <el-input v-model="sendInfo.username" clearable size="small" placeholder="输入缴费人员"></el-input>
                </el-form-item>
                <el-form-item label="缴费名称">
                  <el-input
                    v-model="sendInfo.payname"
                    clearable
                    size="small"
                    placeholder="输入缴费项目/名称"
                  ></el-input>
                </el-form-item>
                <el-form-item label="支付类型">
                  <el-select
                    v-model="sendInfo.costtype"
                    placeholder="输入支付类型"
                    size="small"
                    autocomplete="off"
                    style="width:100%"
                    clearable
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="支付状态">
                  <el-select
                    v-model="sendInfo.coststatus"
                    placeholder="选择支付状态"
                    size="small"
                    autocomplete="off"
                    style="width:100%"
                    clearable
                  >
                    <el-option
                      v-for="item in options1"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value1"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="支付时间">
                  <div class="block">
                    <el-date-picker
                      v-model="sendInfo.costtime"
                      type="datetimerange"
                      range-separator="至"
                      start-placeholder="开始日期"
                      end-placeholder="结束日期"
                      style="width: 100%;"
                    ></el-date-picker>
                  </div>
                </el-form-item>
                <el-form-item label="缴费金额">
                  <el-input v-model="sendInfo.paymoney" clearable size="small" placeholder="输入缴费金额"></el-input>
                </el-form-item>
                <el-form-item label="缴费优先级">
                  <el-input v-model="sendInfo.paylevel" clearable size="small" placeholder="缴费优先级"></el-input>
                </el-form-item>
                <el-form-item>
                  <el-row style="margin-left: -11px;margin-right:-11px">
                    <el-col :span="12">
                      <el-button size="small" @click="chongzhi" style="width:100%">重置</el-button>
                    </el-col>
                    <el-col :span="12">
                      <el-button
                        size="small"
                        type="primary"
                        @click="getTableData"
                        style="width:100%"
                      >立即查询</el-button>
                    </el-col>
                  </el-row>
                </el-form-item>
              </el-form>
            </el-card>
          </el-col>
          <el-col :span="18" style="width: 75%;">
            <el-card shadow="always" style="margin-left:20px;height:600px">
              <el-row>
                <span style="font-weight: 700;font-size:1.5em">缴费列表</span>
                <el-button
                  style="float:right"
                  type="primary"
                  icon="el-icon-download"
                  size="small"
                >导出</el-button>
              </el-row>
              <div style="margin-top:15px">
                <el-table :data="tableData" border style="width: 100%">
                  <el-table-column prop="payname" label="缴费产品"></el-table-column>
                  <el-table-column prop="username" label="缴费人员">
                    <template slot-scope="scope">
                      <span v-if="scope.row.username == null">暂无</span>
                      <span v-else>{{scope.row.username}}</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="costtype" label="支付类型">
                    <template slot-scope="scope">
                      <span v-if="scope.row.costtype == null">暂无</span>
                      <span v-if="scope.row.costtype == 1">支付宝支付</span>
                      <span v-if="scope.row.costtype == 2">微信支付</span>
                      <span v-if="scope.row.costtype == 3">银联支付</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="paymoney" label="缴费金额">
                    <template slot-scope="scope">
                      <span>{{ scope.row.paymoney }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="paylevel" label="缴费优先级">
                    <template slot-scope="scope">
                      <span>{{ scope.row.paylevel }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="costtime" label="支付时间">
                    <template slot-scope="scope">
                      <span v-if="scope.row.costtime != null ">{{ scope.row.costtime }}</span>
                      <span v-else>暂无</span>
                    </template>
                  </el-table-column>
                  <el-table-column prop="paystatus" label="支付状态">
                    <template slot-scope="scope">
                      <span v-if="scope.row.paystatus == 1">已支付</span>
                      <span v-if="scope.row.paystatus == 2">未支付</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="操作" fixed="right" width="220">
                    <template slot-scope="scope">
                      <el-button size="mini" @click="check1(scope.row)" plain>查看</el-button>
                      <el-button size="mini" plain>导出</el-button>
                      <el-button size="mini" plain type="danger">删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <!-- 分页器 -->
              <!-- <Pagination
                :page="sendInfo.page"
                :componentTotal="componentTotal"
                @changeRows="setRows"
                @changePage="setPage"
              ></Pagination>-->
            </el-card>
          </el-col>
        </el-row>
      </el-main>
    </el-container>
  </div>
</template>
  
  <script>
// import * as XLSX from "xlsx";
// import { xlsx, readFile } from "@/assets/js/xlsx";
import Cookies from "js-cookie";
import Pagination from "@/components/Pagination";
export default {
  data() {
    return {
      labelPosition: "top",
      tableData: [],
      plain: true,
      // componentTotal: 0,
      sendInfo: {
        currPage: 0,
        pageNum: 10
      },
      options: [
        { label: "支付宝支付", value: 1 },
        { label: "微信支付", value: 2 },
        { label: "银联支付", value: 3 }
      ],
      value: "",
      options1: [
        { label: "已支付", value1: 1 },
        { label: "未支付", value1: 2 }
      ],
      value1: "",
      Token: "",
      paystatus: "",
      costtypes: [],
      coststatus: "",
      costtime: ""
    };
  },
  methods: {
    async getTableData() {
      const { data: res } = await this.axios.get(
        "http://community.byesame.com/cost/getPayMessage",
        {
          headers: {
            "X-Litemall-Admin-Token": "d3ead033-d02f-4fb2-bd37-c7f5f9bb5044"
          },
          params: this.sendInfo
        }
      );
      console.log(res);
      this.tableData = res.data;
      // this.componentTotal = res.total;
    },
    // // 导出Excel
    // exportExcel() {
    //   xlsx(this.tableData, this.listHander, "用户信息表");
    // }
    // 分页器
    setRows(n) {
      this.sendInfo.pageNum = n;
      this.getTableData();
    },
    setPage(n) {
      this.sendInfo.currPage = n;
      this.getTableData();
    },
    chongzhi() {
      (this.sendInfo.username = ""),
        (this.sendInfo.payname = ""),
        (this.sendInfo.paystatus = ""),
        (this.sendInfo.costtype = ""),
        (this.sendInfo.costtime = ""),
        (this.sendInfo.paymoney = ""),
        this.getTableData();
    },
    // 点击查看
    check1(row) {
      this.$router.push({
        path: "/charging/inforAdd",
        query: { detailId: row.id }
      });
    }
  },
  mounted() {
    this.Token = Cookies.get("X-Litemall-Admin-Token");
    this.getTableData();
  },
  components: {
    Pagination
  }
};
</script>
  
  <style lang="scss" scoped>
.el-container {
  background-color: rgb(240, 240, 240);
}
.el-main {
  margin: 1.3% 1%;
  padding: 0;
  background-color: #fff;
  .el-card {
    height: 600px;
    padding: 20px;
    overflow-y: scroll;
  }
}
.el-form-item {
  width: 100%;
  margin: 10px 0 10px 0;
}
.el-col {
  padding-left: 11px;
  padding-right: 11px;
}
::v-deep .el-form-item__label {
  height: 32px;
  line-height: 32px;
  padding-bottom: 0;
}
</style>